package com.lmonkey.servlet.cate;

import com.lmonkey.servic.CATAGORYDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/admin/admin_docatedel")
public class DoCateDel extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int id = Integer.parseInt(request.getParameter("id"));
        int count = CATAGORYDao.del(id);

        if (count>0){
            response.sendRedirect("admin_cateselect");
        }else {
            PrintWriter out = response.getWriter();
            out.println("<script>alert('删除失败');location.href='/lyq/admin/admin_cateselect';script>");
            out.close();
        }

    }
}
